<template>
  <div class="message-detail-page">
    <!-- 头部 -->
    <div class="header d-flex align-items-center">
      <router-link to="/notificationT" class="text-dark">
        <i class="bi bi-chevron-left fs-4"></i>
      </router-link>
      <h5 class="mb-0 mx-auto">消息详情</h5>
    </div>
    <!-- 消息详情内容 -->
    <div class="message-detail-container">
      <div class="message-info">
        <h3>{{ message.title }}</h3>
        <p class="message-time">{{ message.time }}</p>
<!--        <p class="message-type">消息类型: {{ messageType === 90 ? '系统消息' : '周测消息' }}</p>-->
        <br>
        <div class="message-content" v-html="message.content"></div>
      </div>
      <br>
      <!-- 接收人列表 -->
      <div class="receiver-list-container">
        <h4>接收人列表</h4>
        <ul class="receiver-list">
          <li v-for="receiver in receivers" :key="receiver.id" :class="{ read: receiver.isRead }">
            {{ receiver.name }}({{ receiver.realName }}) - {{ receiver.isRead ? '已读' : '未读' }}
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import http from "@/router/http";

export default {
  name: 'MessageDetailView',
  data() {
    return {
      message: {
      },
      messageType: null,
      receivers: [
      ]
    };
  },
  mounted() {
    this.informId = this.$route.params.id;
    this.getMessageDetail();
  },
  methods: {
    //请求后端接口查询消息详情
    async getMessageDetail() {
      await http.get(`/admin/inform/selectDetailForTeacher/${this.informId}`).then(res => {
        if (res.data.code === 1) {
          this.message = {
            id: res.data.response.informId,
            title: res.data.response.informTypeStr,
            content: res.data.response.content,
            time: res.data.response.createTime,
          };
          this.messageType = res.data.response.informType;
          if(res.data.response.informUserInfoList && res.data.response.informUserInfoList.length > 0){
            res.data.response.informUserInfoList.forEach(item => {
              this.receivers.push({
                id: item.acceptUserId,
                name: item.acceptUserName,
                realName: item.acceptRealName,
                isRead: item.isread == 0 ? true : false,
              });
            });
          }
        }

      });
    }
  }

};
</script>

<style scoped>

/* 头部样式 */
.header {
  background: linear-gradient(135deg, #00b8a9 0%, #28df99 100%);
  color: white;
  padding: 15px 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  margin-bottom: 20px;
}

.message-detail-container {
  background-color: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.message-info {
  margin-bottom: 20px;
}

.message-info h3 {
  font-size: 24px;
  margin-bottom: 10px;
  color: #333;
}

.message-time {
  font-size: 14px;
  color: #999;
  margin-bottom: 10px;
}

.message-type {
  font-size: 16px;
  color: #666;
  margin-bottom: 20px;
}
.header .bi-chevron-left {
  color: white;
  transition: color 0.3s ease;
}
.message-content {
  font-size: 16px;
  line-height: 1.6;
  color: #333;
}

.receiver-list-container {
  margin-top: 20px;
}

.receiver-list-container h4 {
  font-size: 20px;
  color: #333;
  margin-bottom: 10px;
}

.receiver-list {
  list-style: none;
  padding: 0;
}

.receiver-list li {
  padding: 10px;
  border-bottom: 1px solid #eee;
  font-size: 16px;
  color: #333;
}

.receiver-list li.read {
  color: #999;
}
</style>